<div id="i-LogoBar" class="clearfix">
    <a href="/"><div class="t-logo"></div></a>
    <div class="t-search clearfix">
        <input type="text" placeholder="请输入关键词" class="t-search-word">
        <button class="t-search-btn">搜索</button>
        <ul class="t-search-word">
            <li>热门搜索：</li>
        </ul>
    </div>
    <div class="t-tell">
        <span>24小时客服电话：</span>
        <p>4006-0999-27</p>
    </div>
</div>
<script>
    $.post('/index.php/area/word', {'_token':'<?php echo e(csrf_token()); ?>'},function (data) {
        if(data.res){
            for (var i = 0;i<data.searchWords.length;i++){
                var li = $("<li><a href='#'>"+data.searchWords[i]+"</a></li>");
                $(".t-search-word").append(li);
            }
        }
    });
    $(".t-search-btn").click(function () {
        var word = $(".t-search-word").val();
        if (word == ''){
            return;
        }
        $(".t-loading-word").html('查询中');
        $(".t-loading").show();
        $.post('/index.php/search/area',{'word':word,_token:"<?php echo e(csrf_token()); ?>"},function (data) {
            setTimeout(function () {
                $(".t-loading").hide();
                window.open(data.url);
            },1000);
        });
    });

    $('.t-search-word').bind('keyup', function(event) {
        if (event.keyCode == "13") {
            //回车执行查询
            var word = $(".t-search-word").val();
            if (word == ''){
                return;
            }
            $(".t-loading-word").html('查询中');
            $(".t-loading").show();
            $.post('/index.php/search/area',{'word':word,_token:"<?php echo e(csrf_token()); ?>"},function (data) {
                setTimeout(function () {
                    $(".t-loading").hide();
                    window.open(data.url);
                },1000);
            });
        }
    });
</script>